import React, {memo, useEffect, useState} from 'react';
import {getArticleListByClassifyId} from "@/network/archives.request";
import {AdminArticleListWrapper} from "./style";

export default memo(function AdminArticleList(props) {
  const {userId, classifyId} = props;
  const [articleList, setArticleList] = useState([]);

  useEffect(() => {
    if (userId && classifyId) {
      getArticleListByClassifyId(classifyId, userId).then(res => {
        setArticleList(res)
      }).catch(console.log)
    }
  }, [userId, classifyId])

  return (
    <AdminArticleListWrapper className="no-scrollbar">
      {
        articleList && articleList.length > 0 && articleList.map(item => {
          return (
            <li key={item.id}>
              <span className="px-2" style={{display: "inline-block",minWidth: "30px"}}>{item.id}.</span>
              {item.title}
            </li>
          )
        })
      }
    </AdminArticleListWrapper>
  )
})